package bairui.international.weixin.portal.miniapp.controller.proxy.area;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_User;
import bairui.international.service.Service_User;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 *
 * 列表
 *
 * @generated
 * 
 * @see STest_C_Proxy_Area_ListWithProduct_Get 测试
 *
 */
@Controller
public class C_Proxy_Area_ListWithProduct_Get
 extends SC_Proxy_Area_ListWithProduct_Get 
{
	
	@Autowired private Service_User service_User;
	
	/**
	 * Get请求
	 */
	@Action(Get.class)
	@GetMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request, 
		@PathVariable(name=Get.PathVariableName.ProductId) long productId,
		@RequestParam String skey
	) throws Exception {
		TB_User user = service_User.findOne(it->it.skey.eq(skey));
		if(null == user){
			throw new NullPointerException();
		}
		return null;
//		return service_ProxyArea
//				.list(it->it.user.eq(user).and(it.product.id.eq(productId)))
//				.stream()
//				.map(it->new Output(
//						new IdOutput(productId, it.getTown().getId()), 
//						new AddressDataOutput(it.getProxyAreaAddress().getUsername(), it.getProxyAreaAddress().getPhone(), it.getProxyAreaAddress().getFixAddress(), it.getProxyAreaAddress().getAddress())
//					))
//				.collect(Collectors.toList());
	}
	
	@AllArgsConstructor
	private static class Output {
		private @Getter IdOutput id;
		private @Getter AddressDataOutput addressData;
	}
	
	@AllArgsConstructor
	private static class AddressDataOutput{
		private @Getter String username;
		private @Getter String phone;
		private @Getter String fixAddress;
		private @Getter String address;
	}
	
	@AllArgsConstructor
	private static class IdOutput{
		private @Getter Long productId;
		private @Getter Long townId;
	}

}
